|
home / informatica / delphi (navigation links) |
After the Acropolis, Delphi is the most popular archaeological site in Greece. |
| DOS | File Extensions | Threads | MQ | Tic-Tac-Toe | Indy Ping | Send Mail | get HTML | SNMP | Tricks (INI files) | DB2 | XE7 | Links | End |
| Codi | Items | Got | Dev Guide | MQ Delphi / Embarcadero | Net | WebCam | Children | Embarcadero XE7 | Pending | Dubtes | Links |
|
Drawing a line
TCanvas.MoveTo() method takes two arguments, x and y, that represent the point where the line would start. To draw a line from point A to point B, you use the TCanvas.LineTo() method. This method also takes two arguments that specify the end point of the line. procedure TForm1.FormPaint ( Sender: TObject ) ;
begin
Canvas.MoveTo ( 20, 15 ) ;
Canvas.LineTo ( 150, 245 ) ;
end;
Reposicionament del (0,0) i del sentit creixent dels eixos : SetMapMode( Image1.Canvas.Handle, MM_ISOTROPIC);
SetViewportOrgEx( Image1.Canvas.Handle, 20, 180, nil) ; // (X,Y)
|
|
PP4D nice code :
Canvas Demo ;
drawing on canvas ;
drawing on a PaintBox ;
drawing on an Image,
- recommended by
DelphiLand :
Like with a TPaintBox, you can draw items on the canvas of a TImage control.
But a TImage will refresh itself when necessary,
the image will be redrawn without your help if the image is moved or minimized or has other forms popup over it.
This is not the case with a TPaintBox: it's the programmer's job to make sure that it knows how to "repaint" itself.
Graphics TCanvas class Methods, Properties, Events, Members - *** ALL ***
Like with a TPaintBox, you can draw items on the canvas of a TImage control. But a TImage will refresh itself when necessary; the image will be redrawn without your help if the image is moved or minimized or has other forms popup over it. This is not the case with a TPaintBox: it's the programmer's job to make sure that it knows how to "repaint" itself. Try this code :
Design time :
If you can't make it with align props, handle the OnResize event of the panels' container.
From Embarcadero
TColor :
If you specify TColor as a specific 4-byte hexadecimal number instead of using the constants defined in the Graphics unit,
the low three bytes represent RGB color intensities for blue, green, and red, respectively.
The value $00FF0000 represents full-intensity, pure blue,
$0000FF00 is pure green,
and $000000FF is pure red.
$00000000 is black
and $00FFFFFF is white.
4-th byte use :
If the highest-order byte is zero, the color obtained is the closest matching color in the system palette.
If the highest-order byte is one ($01 or 0x01), the color obtained is the closest matching color in the currently realized palette.
If the highest-order byte is two ($02 or 0x02), the value is matched with the nearest color in the logical palette of the current device context.
Nice (Pere's) colors : Color := $DDEEFF ; and Color := $EFFFEF ;
efg :delphi graphics : algorithms {****}
From "graphics.pas" :
Kuki at Delphi :
MyTime := FormatDateTime( '"Actual Time is "' + LongTime Format, Now ) ; Edit1.Text := TimeToStr(Time) + ' - Has pitjat el boto 2.' ; More sophisticated DataTime encoding function EncodeDateTime ( const Year, Month, Day, Hour, Min, Sec, MSe : Word ) : TDateTime ;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Get Environment Var : szMqServer := GetEnvironmentVariableAsString ( 'MQSERVER' ) ;
function GetEnvironmentVariableAsString ( const VarName : string ) : string ;
var bsz : Integer ;
begin
// Get required buffer size (including terminal #0)
bsz := GetEnvironmentVariable ( PChar ( VarName ), nil, 0 ) ;
if bsz > 0 then begin
// Read env var value into result string
SetLength ( Result, bsz - 1 ) ;
GetEnvironmentVariable ( PChar ( VarName ), PChar ( Result ), bsz ) ;
end else // No such environment variable
Result := '' ;
end;
Una altra aportació d'en Pere ! I una altra a continuació ...
szMQServer := GetEnvironmentVariable ( 'MQSERVER' ) ;
La forma d'aquesta variable es SAG.SVRCONN/TCP/11.22.33.44(2416)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Execution window position
Delphi situa la main form depenent de la property Position. Quan és poDesigned, Delphi crea la finestra en el lloc en que l'has situat quan l'estàs dissenyant. Pots provar poScreenCenter, o poDefaultSizeOnly. També pots restaurar la posició on l'ha deixat l'usuari la darrera vegada que ha executat el teu programa. Per fer-ho, has de guardar la posició en el moment de tancar la finestra i restaurar-la en obrir-se un altre cop. Per exemple, mitjançant el fitxer "ini" |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
How to end a Delphi program
If you are used to working in the form unit, you know you need to call Close or Application.Terminate to cause your program to end.
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
Lo més estandard és el mètode Close de la main form. D'aquesta manera executes tots els handlers ....
Una altra manera és Application.Terminate, però no crida onCloseQuery ni onClose. Mata l'aplicació. Finalment, pots passar dels mètodes de les classes i anar directament a matar el procés, usant Halt. No executa cap codi. Només en casos extrems de "Abormal Termination". How to hide from Close Program
When you press the Ctrl-Alt-Del key combination the "Close Program" dialog box pops up. One simple way to hide your program from that dialog (the Task Manager dialog) is to clear the Application object's Title. If a program's main window does not have a title, Windows does not put the program in the "Close Program" dialog window. Remember that in Delphi the so called "main" window is not the Application window. The best place to clear the Title property is inside the Project's source code. To see the Project source, select Project|View Source in the IDE. After the Application.Initialize add the bolded line: Application.Initialize ;
Application.Title := '' ;
Application.CreateForm(TForm1, Form1) ;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MEMORYSTATUS
procedure TForm1.Button1Click(Sender: TObject) ;
var MemoryStatus: TMemoryStatus ;
begin
MemoryStatus.dwLength := SizeOf(MemoryStatus) ;
GlobalMemoryStatus(MemoryStatus) ;
with MemoryStatus do begin
say(IntToStr(dwLength) + ' Size of ''MemoryStatus'' record') ; { Size of MemoryStatus record }
say(IntToStr(dwMemoryLoad) + '% memory in use') ; { Per-Cent of Memory in use by your system }
say(IntToStr(dwTotalPhys) + ' Total Physical Memory in bytes') ; { Amount of Total Physical memory allocated to your system }
say(IntToStr(dwAvailPhys) + ' Available Physical Memory in bytes') ; { Amount available of physical memory in your system }
say(IntToStr(dwTotalPageFile) + ' Total Bytes of Paging File') ; { Amount of Total Bytes allocated to your page file }
say(IntToStr(dwAvailPageFile) + ' Available bytes in paging file') ; { Amount of available bytes in your page file }
say(IntToStr(dwTotalVirtual) + ' User Bytes of Address space') ; { Amount of Total bytes allocated to this program (generally 2 GB of virtual space) }
say(IntToStr(dwAvailVirtual) + ' Available User bytes of address space') ; { Amount of available bytes that is left to your program to use }
end;
end;
O, en una versió més reduida (Unit "mem_sag") : function Mostrar_Memory_Status ( ) : string ;
var MemoryStatus: TMemoryStatus ;
begin
MemoryStatus.dwLength := SizeOf ( MemoryStatus ) ;
GlobalMemoryStatus ( MemoryStatus ) ;
with MemoryStatus do begin
Mostrar_Memory_Status := IntToStr ( dwAvailVirtual ) ;
end ; // with
end ; // Mostrar_Memory_Status
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Input parameters
if paramcount > 0 then
for i := 1 to paramcount do
begin
szStatus := '>>> Param (' + IntToStr(i) + ') is (' + paramstr(i) + ').' ;
Posar_Status ( szStatus ) ;
end ;
if ( ParamCount > 0 )
then begin
fInName := ParamStr(1) ;
end ; { if ... }
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Init vars
Crida : FillChar(NTPDataGram, SizeOf(NTPDataGram), 0);
Definicio : var
NTPDataGram : TNTPGram ;
type TNTPGram = packed record // NTP Datagram format
Head1 : byte;
Head2 : byte;
RootDelay : longint;
RootDispersion : longint;
RefID : longint;
Ref1 : longint;
Ref2 : longint;
Org1 : longint;
Org2 : longint;
Rcv1 : longint;
Rcv2 : longint;
Xmit1 : longint;
Xmit2 : longint;
end ;
How to read a "record" from a file
Jo crearia un arxiu de texte tipus CSV (que té l'avantatge que el pots editar amb Excel) "10.139.130.65","Campanar ST1/AP1",1000,"http://guifi.net/en/node/30648"
"10.139.238.65","Campanar ST2/AP4",400,"http://guifi.net/en/guifi/device/24363"
"10.139.238.33","Campanar ST1/AP2",800,""
"10.139.130.97","Campanar ST2/AP3",2200,""
... i després el llegiria en un StringList i el parsejaria linia a linia amb un altre StringList var i : integer ;
lines : TStringList ;
lineparsed : TStringList ;
parsed : record
ip : string ; // 0
description : string ; // 1
power : integer ; // 2
home : string ; // 3
end ;
begin
lineparsed := TStringList.Create ;
lineparsed.Delimiter := ',' ;
lineparsed.StrictDelimiter := true ;
lines := TSTringList.Create ;
lines.loadFromFile(aFileName) ;
for i:=0 to lines.Count-1 do
begin
lineparsed.Clear;
lineparsed.DelimitedText := lines[i] ;
parsed.ip := lineparsed [0] ;
parsed.description := lineparsed [1] ;
parsed.power := StrToInt( lineparsed [2] ) ;
parsed.home := lineparsed [3] ;
// do something with parsed record
end;
end;
Gracies, Pere ! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Beep
procedure PlayBeep ( ActionType: TMsgDlgType ) ;
var mb: dWord;
begin
case ActionType of
mtInformation: mb := MB_ICONASTERISK ; // SystemAsterisk
mtWarning: mb := MB_ICONEXCLAMATION ; // SystemExclamation
mtError: mb := MB_ICONHAND ; // SystemHand
mtConfirmation: mb := MB_ICONQUESTION ; // SystemQuestion
mtCustom: mb := MB_OK ; // SystemDefault
else
mb:= $0FFFFFFFF ; // Standard beep using the computer speaker
end;
MessageBeep(mb) ;
end;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
File Search
procedure TForm1.Button1Click(Sender: TObject);
var
Search_Result : TSearchRec ;
INstring, OUTstring : string ;
begin
INstring := Edit1.Text ;
StringGrid1.RowCount := 0 ;
debugMsg ( 'Boto-1. Busquem {' + INstring + '}.' ) ;
if FindFirst ( INstring, faAnyFile, Search_Result ) = 0
then begin
repeat
OUTstring := Search_Result.Name +
' ' + IntToStr ( Search_Result.Size ) +
' ' + DateTimeToStr ( FileDateToDateTime( Search_Result.Time) ) ;
StringGrid1.RowCount := StringGrid1.RowCount + 1;
StringGrid1.Cells [ 1, StringGrid1.RowCount - 1 ] := Search_Result.Name ;
StringGrid1.Cells [ 2, StringGrid1.RowCount - 1 ] := IntToStr( Search_Result.Size ) ;
debugMsg ( '+++ Trobat {' + OUTstring + '}.' ) ;
until FindNext ( Search_Result ) <> 0 ;
FindClose ( Search_Result ) ;
end else begin
debugMsg ( '--- No trobat.' ) ;
end ;
end; // Button1 Click
procedure TForm1.Button2Click(Sender: TObject);
var OriginDir, FileToFind : string ;
begin
OriginDir := 'c:\Program Files\MyOrigin\' ;
debugMsg ( 'Boto-2. Busquem {' + OriginDir + '}.' ) ;
FileToFind := FileSearch ( Edit1.Text, OriginDir ) ; // Name DirList
if FileToFind = '' then
ShowMessage('Couldn''t find ' + Edit1.Text + '.')
else
ShowMessage('Found ' + FileToFind + '.');
end;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hex Dump
const HexN: array [ 0..15 ] of char = '0123456789ABCDEF' ;
function HexB ( b: byte ) : string ;
begin
HexB:= HexN [ b shr 4 ] + HexN [ b and $0F ] ;
end;
function HexC ( c: char ) : string ;
begin
HexC := HexB ( byte(c) ) ;
end;
function HexW ( w: word ) : string ;
begin
HexW := HexB ( Hi(w) ) + HexB ( Lo(w) ) ;
end;
function HexDW ( i: Integer ) : string ;
begin
HexDW := HexW ( word (i shr 16) ) + HexW ( word (i) ) ;
end;
procedure Hex_Dump ( msgPtr : PtrMsgRecord ; tLB : TListBox; pDades : pointer ; iLlargada : integer ) ;
var
iCnt : integer ;
szHex : string ;
begin
debugMsg ( msgPtr, '#### Hex Dump. Ptr {' + Format( '0x%8p', [pDades] ) + '}, lng {'+ IntToStr( iLlargada) + '}.' ) ;
iCnt := 0 ;
szHex := '' ; // init empty string
szAux := '' ;
while ( iCnt < iLlargada ) do
begin
szAux := Format ( '%2.2X', [ byte( pDades^ ) ] ) ; // get a byte from memory and format it
Inc ( pByte(pDades) ) ; // first cast it to a pointer of a type, so the compiler knows how to increase your pointer.
iCnt := iCnt + 1 ;
szHex := szHex + szAux ;
szAux := '' ;
if ( length( szHex ) > 46 ) then // 15 items of 3 chars + 1 item of 2 chars
begin
debugMsg ( msgPtr, '#### Hex Dump. Data {' + szHex + '}.' ) ;
szHex := '' ;
end else begin
szHex := szHex + '-' ;
end ;
end ;
end ; // Hex_Dump()
Used in \\MQ\Eines\AMQSCNXC_proves_Conexio_Client\IMI_Buscar_Max_Conexiones\thread_conexio.pas and sag_hexdump unit generated. Sample in "c" |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Port Paralel
procedure TForm1.ScrollBar1Change ( Sender : TObject ) ;
var bWriteMe, bErr : byte ;
function Out32 ( wAddr : word; bOut : byte ) : byte ; stdcall ; external 'inpout32.dll' ;
begin
bWriteMe := ScrollBar1.position ;
Label1.caption := IntToStr ( bWriteMe ) ;
bErr := ( Out32 ( $378, bWriteMe ) ) ;
end ;
Get INPOUT32.DLL
here ;
good description,
how it works,
Programming For Parallel Port Device {interessant : VC++, Delphi, lots of code} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Standard Routines
The table below lists frequently used procedures and functions found in Borland product libraries. This is not an exhaustive inventory of standard routines.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Delphi String Types
A string represents a sequence of characters var MyString : string ;
The standard function Length returns the number of characters in a string. The SetLength procedure adjusts the length of a string. You can index a string variable just as you would an array. First char is "1" and last is "length()". You can assign the value of a string constant--or any other expression that returns a string--to a variable. The length of the string changes dynamically when the assignment is made. Examples: MyString := 'Hello world!';
MyString := 'Hello ' + 'world';
MyString := MyString + '!';
MyString := ' '; { space }
MyString := ''; { empty string }
Help : Find(string) + "About string types" Help : Index(string) + null-terminated strings Els string en Delphi tenen la longitut al davant, i no són compatibles amb els *char de C.
var s:string; p:pchar;
...
s := 'sebas' ;
p := pchar(s) ;
To manipulate null-terminated strings, it is often necessary to use pointers. var P: PChar;
...
P := 'Hello world!';
Points P to an area of memory that contains a null-terminated copy of "Hello world!". This is equivalent to const TempString: array[0..12] of Char = 'Hello world!'#0;
var P: PChar;
...
P := @TempString[0];
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
String Formatting Routines
FmtLoadStr function
Returns formatted output using a resourced format string.
FmtStr procedure
Assembles a formatted string using a format string and an array of arguments.
Format function
Returns a formatted string assembled from a format string and an array of arguments.
FormatBuf function
Formats the arguments from an array, placing the result in a buffer.
FormatMaskText function
Returns a string formatted using an edit mask.
GetFormatSettings procedure
Resets the date and number format parameters to initial values.
GetLocaleFormatSettings procedure
Populates a TFormatSettings data structure.
StrFmt function
Formats entries in an array.
StrLFmt function
Formats a series of arguments from a specified open array into a buffer.
WideFormat function
Returns a formatted Unicode string assembled from a format string and an array of arguments.
WideFormatBuf function
Formats the arguments from an array, placing the result in a buffer.
String functions
What is the Delphi equivalent on C+ " strncpy ? procedure Move ( const SourcePointer; var DestinationPointer; CopyCount : Integer ) ; [url]
function StrCopy ( Dest: PChar; const Source: PChar) : PChar ;
Sample : procedure TForm1.Button1Click(Sender: TObject);
var
Buffer: PChar ;
begin
GetMem ( Buffer, Length ( Label1.Caption ) + Length ( Edit1.Text ) + 1 ) ;
StrCopy ( Buffer, PChar ( Label1.Caption ) ) ; // destinacio, origin.
StrCat ( Buffer, PChar ( Edit1.Text ) ) ;
Label1.Caption := Buffer ;
Edit1.Clear ;
FreeMem ( Buffer ) ;
end;
function StrpCopy ( Dest: PChar; const Source: string ) : PChar ;
Use StrPCopy
to change a Pascal string into a PChar, or zero-based Char array.
[url]
Example :
uses Sysutils ;
var
A : array [0..79] of Char ;
S : string ;
begin
S := 'Honk if you know Basile' ;
StrpCopy ( A, S ) ; // destination (array), origin (string).
Canvas.textout ( 10, 10, string(A) ) ;
end ;
*** RTL Reference *** |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
How to display
ShowMessage ( szSAG + IntToStr(lng) ) ;
Application.MessageBox ( SecondHalf, 'Second Half', 0 ) ;
// Did the directory get created OK?
error := IOResult;
if error = 0
then ShowMessage('Directory created OK')
else ShowMessageFmt('Directory creation failed with error %d',[error]);
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
my program ID
const
szProducte = 'Size Resources on MQ Server - MultiThread' ;
szAutor = 'sebas@tinet.cat' ;
szVersio = 'v 1.0.f-07, 20121019' ;
Label29.Caption := szProducte + szVersio + szAutor + DateToStr( Date(now) ) ;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
How do we create Windows Services in Delphi?
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Console Application
3 ways to do it :
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Basic File I/O
var
fileInputData : TextFile ;
iIORC : integer ;
iNumLines : integer ;
InputDataLine : string ;
begin
AssignFile ( fileInputData, kIniFilename ) ;
FileMode := 0 ; // Set file access to read only
{$I-} // turn OFF I/O checking. "{$IOChecks off}"
Reset ( fileInputData ) ;
iIORC := IOResult ; [url]
iNumLines := 0 ;
while not EOF ( fileInputData ) do
begin
Readln ( fileInputData, InputDataLine ) ;
iNumLines := iNumLines + 1 ;
debugMsg ( 'Linea (' + IntToStr(iNumLines) + ') = {' + InputDataLine + '}.' ) ;
end ; // eof(fileInputData)
CloseFile ( fileInputData ) ;
{$I+} // turn ON I/O checking
debugMsg ( 'Llegides (' + IntToStr(iNumLines) + ') linies.' ) ;
File I/O - Delphi Examples
There are 3 basic methods to perform File I/O
FileMode
NormalMode = $02 ; { ---- 0010 }
ReadOnly = $00 ; { ---- 0000 }
WriteOnly = $01 ; { ---- 0001 }
ReadWrite = $02 ; { ---- 0010 }
DenyAll = $10 ; { 0001 ---- }
DenyWrite = $20 ; { 0010 ---- }
DenyRead = $30 ; { 0011 ---- }
DenyNone = $40 ; { 0100 ---- }
NoInherit = $70 ; { 1000 ---- }
(filutilh.inc) : const fmShareDenyNone = $0040 ; I/O rc's
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Window control
if ( WindowState = wsNormal ) or ( WindowState = wsMaximized ) then
WindowState := wsNormal ;
Full Screen
procedure TForm1.FormCreate ( Sender: TObject ) ;
begin
BorderStyle := bsNone ; // turn off the form's border
WindowState := wsMaximized ; // maximize window to screen size
end;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Debug or Trace ListBox
Fitxer "SAG_debug.pas" a \\Delphi\Units\. Posar "SAG_debug," al "Uses" ... procedure debugMsg ( s: string ) ;
const MaxNumofItems = 1000 ; NumItemstoDelete = 500 ;
var i : integer ;
begin
with Form1.Listbox2 do begin
if Items.Count > MaxNumofItems then begin
for i:=1 to NumItemstoDelete do
Items.Delete(0);
end;
Items.Add ( dateTimeToStr ( now ) + ' ['+inttostr(items.count)+'] ' + s ) ;
ItemIndex := Count - 1 ; // display last item (maybe scrolled)
ItemIndex := -1 ; // no focus at all = remove focus
end;
end ; (* debugMsg *)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Timer
The "Timer" object has 1 event ("OnTimer") and 4 properties:
procedure debugMsg ( s: string ) ;
begin
if not bLB_Enabled then Exit ;
with Form1.ListBox1 do begin
Items.add ( dateTimeToStr ( now ) + ' ' + s ) ;
ItemIndex := Count - 1 ; // focus on last item
ItemIndex := -1 ; // no focus
end;
end;
procedure TForm1.MyShow(Sender: TObject);
begin
Timer1.Enabled := False ;
iInterval := 1000 ;
Timer1.Interval := iInterval ;
debugMsg ( 'Interval is (' + IntToStr(iInterval) + ').' ) ;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
debugMsg ( 'Hola.' ) ;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled := not (Timer1.Enabled) ;
if Timer1.Enabled
then Button1.Caption := 'Stop.'
else Button1.Caption := 'Start.' ;
end;
end.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Time Period
uses DateUtils ;
var
tim_Inicio_Periodo, tim_Final_Periodo : TDateTime ;
i64_Lapso : Int64 ;
tim_Inicio_Periodo := Time() ;
repeat
tim_Final_Periodo := Time() ;
i64_Lapso := MilliSecondsBetween ( tim_Final_Periodo, tim_Inicio_Periodo ) ;
until ( i64_Lapso > k_Thread_Delay_mSg ) ;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
PageControl
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Semaphores & Mutexes
There is one very big difference between semaphores and mutexes, however. While a mutex can be acquired by no more than one thread or process at a time, semaphores can be designed to allow two or more threads to acquire the semaphore simultaneously. A thread gets ownership of a mutex by specifying a handle of the mutex in one of the wait functions, as WaitForSingleObject. The ReleaseMutex function releases ownership of the specified mutex object.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Q:
A:
The TService class encapsulates a Windows NT service in an NT service application. A service is accessed via the Service Control Manager. It is usually started during boot time or manually in the control panel 'Services' applet. The code will look as shown in the example below and consult the online help about TService. You may want to handle the OnExecute event.
type
TService1 = class(TService)
private
{ private declarations }
public
function GetServiceController: TServiceController; override;
end;
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Enumerating enumerated type
uses typinfo ;
Type ptypeinfo = ^ ttypeinfo ; // http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/TypInfo_PTypeInfo.html
procedure TForm1.IdcmpClientReply( ASender: TComponent; const AReplyStatus: TReplyStatus ) ;
var
iRepQ : integer ;
pInfo : pTypeInfo ;
szEnumName : string ;
begin
iRepQ := ord( AReplyStatus.ReplyStatusType ) ;
pInfo := System.TypeInfo( TReplyStatus ) ; // returns a pointer to a TTypeInfo record.
szEnumName := TypInfo.GetEnumName( pInfo, iRepQ ) ;
// S := typinfo.getenuname( system.typeinfo( tstatustype), ord(replystatus) );
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Delphi 5 service
An NT service application is a 32-bit Windows application
that can run without requiring a user to be logged on.
In fact, NT service applications seldom interact with the desktop at all.
program ServProj;
uses
SvcMgr,
Server42 in 'Server42.pas'{Service1: TService};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TService1, Service1);
Application.Run;
end.
However, there are some differences in this code.
For example, the Forms unit has been replaced by the SvcMgr unit.
As a result, the Application variable is not of type TApplication
but of type TServiceApplication
(taking care of the NT service application details for us).
If you switch to the Server42 unit, you’ll see
that it looks similar to a Delphi data module.
And as with a data module, you can add just about any
nonvisual component to the new service.
But remember that you’re restricted
to nonvisual components; you'll get an exception
"Controls Cannot Be Added To A Service" message
if you try to drop a visual component.
|
Delphi wants a DPR file as the project's root.
To Copy/Rename a complete project, only DFM, DPR and PAS files are required.
DFM files can be saved in Binary or Text format. Text is better, and is selected by ... selecting "Text DFM" when viewing a Form and left button is used.
URL.
A complete project looks like this
First, lets delete unused files :
Now lets modify them a bit
Remove Vcl. from
Also, remove the MainFormOnTaskbar line
Remove all prefixes as Winapi., System. and Vcl. from
|
Dialog Boxes the Delphi way
A modal dialog box is one that must be dismissed before the user can continue using the application. A modeless dialog box is one that allows the user to continue to work with the application while the dialog box is displayed. To execute a modal dialog box, you call the ShowModal method of TForm. To create a modeless dialog box, you call the Show method. |
||||||||||||||||||
| To create an MDI (Multiple Document Interface) application in Delphi, you must set the main form's FormStyle property to fsMDIForm. Each of the MDI child windows must have the FormStyle property set to fsMDIChild. | ||||||||||||||||||
| If you have multiple components selected on the form, the Object Inspector shows all the properties that those components have in common. You can use this feature to modify the properties of several components at one time. | ||||||||||||||||||
|
||||||||||||||||||
|
Available objects
Edit controls display text to the user and allow the user to enter text.
|
||||||||||||||||||
|
Lists
Lists present the user with a collection of items to select from. Several components display lists:
Form1.ListBox1.Style : TListBoxStyle ;
lbOwnerDrawFixed, lbOwnerDrawVariable,
lbStandard, lbVirtual, lbVirtualOwnerDraw
Form1.ListBox1.Autocomplete : boolean ;
Form1.ListBox1.Align : TAlign ;
Form1.ListBox1.Anchors : TAnchors ;
Form1.ListBox1.Color : TColor ;
Form1.ListBox1.Style : TListBoxStyle ;
Form1.ListBox1.Items : TStrings ;
Form1.ListBox1.Items.SaveToFile( Edit4.Text ) ; save ListBox to File
ListBox3.Items.LoadFromFile( OpenDialog1.Filename ) ; load ListBox from File
Form1.ListBox1.Items.Count = number of items in list
Form1.ListBox1.ItemIndex = selected item in list ( -1 = none ? )
i := LB1.ItemIndex ; // get selected item index.
szOut := LB1.Items.Strings[i] ; // get selected text.
ListBox scrollbars
To make sure that the horizontal scrollbar appears, set ListBox.ScrollWidth (1000) to a value larger than the width of the ListBox (300). |
||||||||||||||||||
|
CheckBox and RadioButton
CheckBox versus RadioButton
CheckBox indicate a user selection, being multiple choices possible. Radio buttons, also called option buttons, present a set of mutually exclusive choices. CheckBox :
|
||||||||||||||||||
|
mobile Tedit contents
We want to copy TEdit's contents in a loop way : for i := 1 to kMaxTB-1 do
begin
TBx[i].Text := TBx[i+1].Text ; // moure els valor vells ...
end ;
TBx [kMaxTB].Text := IntToStr( iFondaria ) ; // ... i afegir el valor nou
Manual init is like TBx[1] := eX1 ; TBx[2] := eX2 ; TBx[3] := eX3 ;
And clever one (Pere's again here) : for i := Low(TBx) to High(TBx) do
TBx[i] := FindComponent( 'eX' + IntToStr(i) ) as TEdit ;
And a even more dynamic approach: els pots crear dinàmicament.... for i := Low(TBt) to High(TBt) do
begin
TBt[i] := TEdit.Create(self);
with TBt[i] do
begin
Top := 40 + ( i * 16 ) ;
Left := 40 ;
Visible := True ;
Parent := Panel1 ;
end;
end;
We can find a Edit field using this code (en Pere és un monstre) var e:TEdit ;
if assigned(e) then
e := FindComponent( 'Edit' + IntToStr(i) ) as TEdit ;
e.Text := IntToStr(i) ;
Aqui n'hi ha un altre exemple : procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
const
NamePrefix = 'MyEdit';
begin
for i := 1 to 20 do begin
TEdit.Create(Self).Name := NamePrefix + IntToStr(i) ;
with TEdit ( FindComponent ( NamePrefix + IntToStr(i) ) ) do
begin
Left := 10 ;
Top := i * 20 ;
Parent := self ;
end;
end;
end;
|
||||||||||||||||||
|
String Grid
sg.ColCount := 2 ;
sg.RowCount := 9 ;
sg.FixedCols := 0 ;
sg.FixedRows := 1 ;
sg.Cells[0,0] := 'Centro Comercial' ;
sg.Cells[1,0] := 'Tiempo de Respuesta' ;
| ||||||||||||||||||
|
Menu bar
Create
To assign a Menu to a form, drop a TMainMenu item (from "Standard" tab) on it (default named "MainMenu1"), and add menu items, using "right-click + Menu Designer". It is asigned to the Menu property of the form. Ajustar
Per ajustar el darrer element a la dreta, fem : procedure TForm1.FormCreate(Sender: TObject) ;
var
mii : TMenuItemInfo ;
MainMenu : hMenu ;
Buffer : array [ 0 .. 79 ] of Char ;
begin
MainMenu := Self.Menu.Handle ;
// Get Help Menu Item Info
mii.cbSize := SizeOf(mii) ;
mii.fMask := MIIM_TYPE ;
mii.dwTypeData := Buffer ;
mii.cch := SizeOf(Buffer) ;
GetMenuItemInfo ( MainMenu, HelpMenuItem.Command, false, mii ) ;
// Set Help Menu Item Info
mii.fType := mii.fType or MFT_RIGHTJUSTIFY ;
SetMenuItemInfo ( MainMenu, HelpMenuItem.Command, false, mii ) ;
end ;
Amagar
Per amagar/mostrar el menu, podem fer : // MainForm is the name of the form and menu is "MainMenu1: TMainMenu ;"
// Hide :
MainForm.Menu := nil ;
// Show :
MainForm.Menu := MainMenu1 ;
| ||||||||||||||||||
|
Status bar
Simple: procedure StatusBarWrite ( s : string ) ;
begin
frmBISChttp.sbBISChttp.SimpleText := DateToStr(now) + '. ' + TimeToStr(now) + '. ' + s ;
end ; //
With panels: procedure TfrmTTclient.TT_TimerTimer(Sender: TObject);
begin
sbTT.Panels[0].Text := DateTimeToStr ( now ) ;
end ; // timer timeout
Configuration steps :
|
||||||||||||||||||
|
Progress Bar
Important settings :
procedure TForm1.My_Init(Sender: TObject); // es posa al "OnCreate()" !
begin
Timer1.Interval := 100 ;
Timer1.Enabled := true ;
ProgressBar1.Smooth := true ;
ProgressBar1.Step := 1 ;
iCnt := 0 ;
ProgressBar1.Position := 0 ;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
iRed, iGreen, iBlue, iColor, iOut, iOut2 : integer ;
iSeg, iDec : integer ;
begin
ProgressBar1.StepIt ;
iCnt := iCnt + 1 ;
if ( iCnt >= 100 ) then iCnt := 0 ;
iSeg := iCnt div 10 ;
iDec := iCnt mod 10 ;
Label2.Caption := ' {' + IntToStr(iSeg) + ',' + IntToStr(iDec) + '} seg' ;
iOut2 := 256 * iCnt div 100 ;
iOut := 256 - iOut2 ;
iRed := iOut ;
iGreen := iOut * 256 ;
iBlue := iOut * 256 * 256 ;
iColor := iBlue + iGreen + iRed ;
Panel1.Color := iColor ;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Timer1.Enabled then begin
Timer1.Enabled := false ;
Button1.Caption := 'Re-Start It Again.' ;
end
else begin
iCnt := 0 ;
ProgressBar1.Position := 0 ;
Timer1.Enabled := true ;
Button1.Caption := 'Continue ...' ;
end ;
end;
end.
Progress Bar in a Status Bar !
|
||||||||||||||||||
|
SpinButton
Associate to an Edit field "Value" field ? (telnet) | ||||||||||||||||||
|
Botons i missatges
MessageDlg
Displays a message, symbol, and selectable buttons
function MessageDlg ( const Message : string;
DialogType : TMsgDlgType;
Buttons : TMsgDlgButtons;
HelpContext : Longint ) : Integer ;
|
||||||||||||||||||
|
Object-related events (from Object Inspector)
TForm.Create(AOwner) ?
|
||||||||||||||||||
|
Owner-draw ListBox
Use OnDrawItem to write a handler for drawing of the items in list boxes with the Style values lbOwnerDrawFixed, lbOwnerDrawVariable, or lbVirtualOwnerDraw. OnDrawItem occurs when the list box needs to display an item. OnDrawItem occurs only for owner-draw list boxes. Set the ListBox1.Style prop. to lbOwnerDrawFixed : procedure TTest.ListBox1DrawItem (
Control: TWinControl;
Index: Integer;
Rect: TRect;
State: TOwnerDrawState ) ;
begin
With ( Control As TListBox ).Canvas Do
Begin
Case Index Of
0:
Begin
Font.Color := clBlue;
Brush.Color := clYellow;
End;
1:
Begin
Font.Color := clRed;
Brush.Color := clLime;
End;
2:
Begin
Font.Color := clGreen;
Brush.Color := clFuchsia;
End;
End;
FillRect(Rect); // fill a rectangular region using the current brush
TextOut(Rect.Left, Rect.Top, ( Control As TListBox ).Items[Index]);
End;
end;
|
||||||||||||||||||
|
Imatges and GIFs
Natively, Delphi supports BMP, ICO, WMF and JPG images - these can be loaded into a graphic-compatible component (such as TImage) and used in an application. Per fer servir un "Logo" :
Imatges dinàmiques
[LED_JPG.pas]
var
kVerde, kRojo, kAmarillo: TImage ;
procedure TForm1.MyInit(Sender: TObject);
begin
kVerde.Picture.LoadFromFile ( 'led_verd.JPG' ) ;
kRojo.Picture.LoadFromFile ( 'led_vermell.JPG' ) ;
try // per si no existeix el fitxer ...
kAmarillo.Picture.LoadFromFile ( 'led_groc.JPG' ) ;
except
on Err : Exception do begin
debugMsg ( '--- LoadFromFile() failed. Message ' + Err.Message ) ;
end ;
end ; // except
end; // TForm1.MyInit
{ somewhere else ... }
Image2.Picture := kRojo.Picture ;
{ later ... }
Image2.Picture := kVerde.Picture ;
|
||||||||||||||||||
|
Graphics
To draw graphics in a Delphi application, you draw on an object's canvas, rather than directly on the object. The canvas is a property of the object, and is itself an object. |
||||||||||||||||||
704.868.352 Borland_Delphi_V7.0_Enterprise_studio_1&2cd.ISO
71 delphi.7.serial.txt [*]
584.159 Teach-Yourself-Borland-Delphi-in-21-Days[ebook-html].zip
15.100.391 Borland Delphi 7 Developer's Guide.pdf
720.552.973 Delphi7.iso@500GB USB disk, {D:\ISOs\Delphi_v7}
|
System requirements : (Borland Delphi 7 ? Edition) |
|
|---|---|
| Studio Architect | Pentium 233 MHz XP, 2000, 98 64 MB RAM 520 MB HDD CD-ROM, SVGA, Mouse. |
| Studio Professional | Pentium 233 MHz XP, 2000, 98 64 MB RAM 400 MB HDD CD-ROM, SVGA, Mouse. |
| Studio Enterprise | Pentium 233 MHz XP, 2000, 98 64 MB RAM 450 MB HDD CD-ROM, SVGA, Mouse. |
| Personal | Pentium 233 MHz XP, 2000, 98 32 MB RAM 160 MB HDD CD-ROM, SVGA, Mouse. |
|
On a W95, this message comes up when starting Delphi32.exe :
And also
|
|
| Delphi 7 Enterprise Suite setup launcher : |
|---|
|
We can select :
|
|
This message comes up :
|
|
Features to be installed :
SQL driver configuration :
Choose wheter you use VisiBroker/COBRA Support. Install InterBase Client + Install/Upgrade to Data Access Components 2.7 InterBase 6.5 Server gets installed. Java RTE 1.2.2-001 is installed.
VisiBroker (for C++) 4.5 gets installed.
Docu at file:///d:/Inprise/vbroker/vbcpp.html |
|
Delphi Direct goes to Internet to get news ! |
|
Your Just-in-Time debugger is currently set to
Do you want to change this setting ? |
| Machine | Version |
|---|---|
| T42 | delphi 7 Enterprise (Build 4.453) Registration Key: 2292737. |
| T42 VMware(GN) | delphi 7 [cd1] |
| P4 | delphi 7
"InterBase Guardian" service (Automatic) and "InterBase Server" service (Manual). |
| Kayak | delphi 7 [cd1] |
[cd1] CD "Borland Delpi v 7.0 Enterprise Studio 1 & 2.
As it is an ISO, Daemon shall be used.
|
Developer's Guide lessons
Examining a Delphi objectPage 4-2 : When you create a new project, the IDE displays a new form for you to customize. In the Code editor, the automatically generated unit declares a new class type for the form and includes the code that creates the new form instance. The generated code for a new Windows application looks like this: unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs ;
type
TForm1 = class(TForm) { The type declaration of the form begins here }
private
{ Private declarations }
public
{ Public declarations }
end; { The type declaration of the form ends here }
var
Form1: TForm1;
implementation { Beginning of implementation part }
{$R *.dfm}
end.{ End of implementation part and unit}
Please, read What is "var Form1:TForm1" in Delphi Form's Unit Interface section?, amb preguntes com "Do I need the Form1 global variable?" ... Suppose you add a button component to this form and write an OnClick event handler that changes the color of the form when the user clicks the button. This is the eventhandler code for the button's OnClick event: procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Color := clGreen;
end;
Changing the name of a componentYou should always use the Object Inspector to change the name of a component. Note that the code in the OnClick event handler for the button hasn't changed. Because you wrote the code, you have to update it yourself and correct any references to the form. Scope and QualifiersPage 4-5 : procedure TForm1.Button1Click(Sender: TObject); begin Color := clFuchsia ; Button1.Color := clLime ; end; The first statement is equivalent to Form1.Color := clFuchsia ; You don't need to qualify Color with Form1 because the Button1Click method is part of TForm1; identifiers in the method body therefore fall within the scope of the TForm1 instance where the method is called. The second statement, in contrast, refers to the color of the button object (not of the form where the event handler is declared), so it requires qualification. Types of socket connections
On page 39-3 : Socket connections can be divided into three basic types, which reflect how the connection was initiated and what the local socket is connected to. These are :
Once the connection to a client socket is completed, the server connection is indistinguishable from a client connection. Both end points have the same capabilities and receive the same types of events. Only the listening connection is fundamentally different, as it has only a single endpoint. Sockets
The Internet palette page includes three socket components
that allow your network application to form connections to other machines,
and that allow you to read and write information over that connection.
These are:
Associated with each of these socket components are socket objects, which represent the endpoint of an actual socket connection. The socket components use the socket objects to encapsulate the socket server calls, so that your application does not need to be concerned with the details of establishing the connection or managing the socket messages. If you want to customize the details of the connections that the socket components make on your behalf, you can use the properties, events, and methods of the socket objects. After completing the connection to a client or server socket, you can use the client or server socket object associated with your socket component to obtain information about the connection. Use the LocalHost and LocalPort properties to determine the address and port number used by the local client or server socket, or use the RemoteHost and RemotePort properties to determine the address and port number used by the remote client or server socket. Use the GetSocketAddr method to build a valid socket address based on the host name and port number. You can use the LookupPort method to look up the port number. Use the LookupProtocol method to look up the protocol number. Use the LookupHostName method to look up the host name based on the host machine's IP address. To view network traffic in and out of the socket, use the BytesSent and BytesReceived properties. Threads
For information on how to provide thread support to your application, see Chapter 13, "Writing multi-threaded applications", "Borland Delphi 7 for Windows - Developer's Guide" [\\t400\Delphi\Docu\DevGuide\Borland_Delphi_7_DeveloperS_Guide.pdf] Thread objects do not allow you to control the security attributes or stack size of your threads. If you need to control these, you must use the BeginThread function. Even when using BeginThread, you can still benefit from some of the thread synchronization objects and methods described in "Coordinating threads" on page 13-7. For more information on using BeginThread, see the online Help. On the other hand, because the thread shares the same process space with other threads, you can use the shared memory to communicate between threads. Sometimes, however, you may want to use variables that are global to all the routines running in your thread, but not shared with other instances of the same thread class. You can do this by declaring thread-local variables. Make a variable thread-local by declaring it in a threadvar section. Once you have implemented a thread class by giving it an Execute method, you can use it in your application to launch the code in the Execute method. To use a thread, first create an instance of the thread class. You can create a thread instance that starts running immediately, or you can create your thread in a suspended state so that it only begins when you call the Resume method. To create a thread so that it starts up immediately, set the constructor's CreateSuspended parameter to False. For example, the following line creates a thread and starts its execution:
SecondThread := TMyThread.Create(false) ; { create and run the thread }
Warning - Do not create too many threads in your application. The overhead in managing multiple threads can impact performance. The recommended limit is 16 threads per process on single processor systems. This limit assumes that most of those threads are waiting for external events.
function BeginThread (
SecurityAttributes : Pointer ; // nil is ok
StackSize : LongWord ; // 0 is ok
ThreadFunc : TThreadFunc ; // in : code
Parameter : Pointer ; // in : data
CreationFlags : LongWord ; // 0 is ok
var ThreadId : LongWord // out : unique identifier
) : Integer ; // out : integer used by CloseHandle
Un uso para los threads : lanzar una tarea larga desde un botón. O poder lanzar una tarea "bloqueante" en paralelo con otra que no queremos que se detenga. La funció BeginThread crida les primitives de windows. Crec que és més elegant, més senzill d'usar i més potent, utilitzar TThread. |
Why do we need to use it ?
Answer : to start an asynchronous call as MQ_Get() or MQ_Subscribe() !
The easiest way to create a multithreaded application in Delphi
is to write a thread class that inherits from
TThread
If you don't want to write a class,
you can use
BeginThread
and
EndThread.
They are wrappers for the Win32 API calls
CreateThread
and
ExitThread
functions,
but you must use Delphi's functions instead of the Win32 API directly.
Deplhi keeps a global flag,
IsMultiThread,
which is True if your program calls
BeginThread
or starts a thread using
TThread.
We can create threads using a simple Windows API function called CreateThread to bypass the TThread object altogether.
Sometimes, however, you may want to use variables that are global to all the routines running in your thread, but not shared with other instances of the same thread class. You can do this by declaring thread-local variables. Make a variable thread-local by declaring it in a threadvar section. For example,
Book : Martin Harvey [\\Delphi\MultiThreading\Internet\MartinHarvey]
local sample
dwStackSize = the initial size of the stack, in bytes. The system rounds this value to the nearest page. If this parameter is zero, the new thread uses the default size for the executable.
CreateThread() @ MSDN2 sample.
The default size for the reserved and initially committed stack memory is specified in the executable file header. Thread or fiber creation fails if there is not enough memory to reserve or commit the number of bytes requested. The default stack size used by the linker is 1 MB. To specify a different default stack size for all threads and fibers, use the STACKSIZE statement in the module definition (.def) file. The linker rounds up the specified value to the nearest 4 bytes.
Pere : caldria cridar GetLastError(), no et sembla ?
\\Delphi\Pere\HelloThread\
\\T400\MQ\Eines\AMQSCNXC_proves_Conexio_Client\IMI_Buscar_Max_Conexiones\thread_conexio.pas and \\T400\Delphi\MultiThreading\BuscarLimitThreads\*.pas - Raise
A nice and clean sample code : \\Delphi\MultiThreading\Internet\EjempleFuncional\unit1.pas
Question: the TClientSocket and TServerSocket components seem to be missing from my installation of Delphi 7
Solution:
You need to add the dclsockets package to the IDE.
To do this go to Component | Install Packages | Add (/bin/dclsockets70.bpl).
OK - ja tinc "ClientSocket" i "ServerSocket" a la solapa de "Internet" ...
Q : on és TSpinEdit ?
Sol: The SpinEdit component is in dclsmp70 package, with TGauge, TColorGrid, TSpinButton, TdirectoryOutline and TCalendar.
El pots trobar a la solapa "Samples" !
La idea és primer passar el .H i el .LIB a una unit .PAS
i poder accedir la DLL
El segon pas, construir un component Delphi que representi una qua MQ
Tercer, si cal, contruir una jerarquia de components
que representin la comunicació amb MQ tipo JMS
We want to
We need some files, adapted from CMQC.H :
They are stored in \\T430\Delphi\Units and [tinet]
Finally, functions are declared as C external :
1st declare you gonna use it :
2nd use it to display a var in memory :
There are two units in the package :
The SupportPac contains two files called 'MQI.PAS' and 'MQIC.PAS'. These are Pascal sources that should be placed somewhere in the Search Path of Delphi to be included in your Pascal program. The way to include it is like using any unit in Pascal :
One of the implementations of the MQI (MQSeries Interface) on Windows is the 'C' interface. This interface is implemented by a dynamic link library that holds the calls a 'C' programmer can use to interface with MQ. Pascal implementations like Delphi can call external functions/procedures easily by declaring them as 'external' and 'C' versions by adding 'cdecl'. This is how the MQI units define the calls to the 'C' versions.
The MQI calls in the Pascal unit will resemble the ones described in the MQI 'C' interface, but bear in mind that the 'C' language uses pointers very explicitly and uses another method to determine the length of a string (which is marked by a #0 at the end and therefore 'C' strings are called 'null-terminated'). In Pascal the '@' operator is used to pass a pointer value, so you will see this operator regurarly when calling external procedures that adhere to the 'C' calling interface.
AMQAPI comença amb 3 solapes :
Mostra una drop-down list amb els Queue Managers locals disponibles
i una finestra amb el "Connected Queue Manager".
Les operacions disponibles son :
A la part de sota, com sempre, es mostra una finestra amb els resultats de les operacions, amb 3 camps : MQI (operacio), CC (condition code) i RC (reason code), as
Es mostra el "Connected Queue Manager" (necessari, escollit de abans),
la "Selected Queue" i el "Selected Open Objects"
Les operacions disponibles son :
El CheckBox "Advanced Mode" permet l'accés a totes les opcions (que son moltes) del Open, Get, Put o Close.
A la part de sota, com sempre, es mostra una finestra amb els resultats de les operacions.
Yes - this is the path : Software\\IBM\\MQSeries\\CurrentVersion\\Configuration\\QueueManager
Pseudo URL [\\Delphi\Pere\MQ]
A mi m'agraden més les de dibuix vectorial,
tipus
Corel
Draw.
Jo faig servir el Xara Xtreme.
N'hi han open source com el
Inkscape [P4].
Vector Graphics Editor - Delphi/Timage vol Raster !
O bé fes servir una eina especialitzada en charting,
p.ex. Visio, SmartDraw.
En Jordi em recomana el
GIMP
Per últim, es pot canviar el dibuix dinàmicament, amb Image1.Picture.loadfromfile(filename)
Compte !
Nomes cal llegir del fitxer un cop,
i es pot assignar molts cops :
[\\Delphi\Leds_sobre_JPG\Led_JPG.pas]
[\\Delphi\Port Paralel\port_paralel.pas]
[\\Delphi\units\MQIC.PAS] - see "PDF and Administration Interface"
També "Support Pack" MA7Q = MQI for Delphi
Es complementa amb naturalitat amb \\T430\MQ\Eines\WorkLoader\wlg.c
pending !
See MQCMD_INQUIRE_CHANNEL_STATUS
Using MQIC with Delphi {gone 2013/03}
Jo tinc un directori de "units" meves on hi poso els fonts i els resultats de la compilació. Cal dir-li al Delphi via Project | options | directories | Search Path on són. { SAG = C:\Sebas\Delphi\Units }
Inicialització de la Unit :
Pot no haver objectes, per lo que no hi hauria "OnCreate()" !
At \\Delphi\Units\ tinc :
Les poso a github
Any "old" program shall fail indicating "wrong queue manager name", as in MQ_CONNECT() trace we find :
The name of the queue manager was copied (using StrPCopy()) from a Edit field, that is a "unicode" string
The "correct" parameters shall be:
Efectivament, el nom del gestor és "QM_CNT", 6 lletres.
Solution :
All my unit's have been updated (20150520)
Now, to get the name of a MQ object from a Delphi form we shall use:
Compte amb els compiladors que tenim :
Mentre a l'altre tenim:
Get Client ! here (?)
They also have
2004/10/12 - Borland Delphi 2005 Announced
Class TClientSocket not found.
Indy = Internet Direct - Knowledge base.
If I run a Delphi program trying to access a socket below 1000, I get "socket error 10013 access denied". Solution : set "Admin" access rights for the exe (or its icon)
How to catch it in the code and display a nice message ? See sample.
Some numbers from uSoft, as 10013, "access denied"
| type ClientSocket1: TClientSocket ; //Connect to Server by button click procedure TTCPClient.btConnectClick ( Sender: TObject ) ; begin ClientSocket1.Host := edRemoteIP.Text; ClientSocket1.Port := strtoint(edRemotePort.Text); ClientSocket1.Active := True; end; //event handling and display connection state procedure TTCPClient.OnConnect ( Sender: TObject; Socket: TCustomWinSocket ) ; begin btSend.Enabled := True; btDisconnect.Enabled := True; btConnect.Enabled := False; mbReceiveData.Clear; Statusbar1.SimpleText := 'Connected to ' + ClientSocket1.Host; end; procedure TTCPClient.OnDisconnect ( Sender: TObject; Socket: TCustomWinSocket ) ; begin btSend.Enabled := False; btDisconnect.Enabled := False; btConnect.Enabled := True; Statusbar1.SimpleText := 'No Connection'; end; //Error handling procedure TTCPClient.OnError ( Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer ) ; begin ShowMessage ('Connection Error'); ClientSocket1.Active := False; btSend.Enabled := False; btDisconnect.Enabled := False; btConnect.Enabled := True; Statusbar1.SimpleText := 'No Connection'; end; //send test string by button click procedure TTCPClient.btSendClick ( Sender: TObject ) ; begin ClientSocket1.Socket.SendText (edSendData.Text); edSendData.Text := ''; end; //receive data handling procedure TTCPClient.OnRead ( Sender: TObject; Socket: TCustomWinSocket ) ; begin mbReceiveData.Text := mbReceiveData.Text + ClientSocket1.Socket.ReceiveText; end; //disconnect by button click procedure TTCPClient.btDisconnectClick ( Sender: TObject ) ; begin ClientSocket1.Active := False; end; | type ServerSocket1: TServerSocket ; //start server listening by button click procedure TTCPServer.btListenClick(Sender: TObject); begin If edLocalPort.Text <> '' Then begin ServerSocket1.Port := strtoint(edLocalPort.Text); ServerSocket1.Open; end Else ShowMessage ('No local port!'); end; //event handling and display connection state procedure TTCPServer.OnListen(Sender: TObject; Socket: TCustomWinSocket); begin Statusbar1.SimpleText := 'Listening'; btSend.Enabled := False; btDisconnect.Enabled := False; btListen.Enabled := False; end; procedure TTCPServer.OnAccept(Sender: TObject; Socket: TCustomWinSocket); begin Statusbar1.SimpleText := 'Connected to ' + Socket.RemoteAddress; btSend.Enabled := True; btDisconnect.Enabled := True; end; procedure TTCPServer.OnClientDisconnect(Sender: TObject; Socket: TCustomWinSocket); begin Statusbar1.SimpleText := 'Listening'; ServerSocket1.Open; btSend.Enabled := False; btDisconnect.Enabled := False; end; //error handling procedure TTCPServer.OnClientError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); begin ShowMessage ('Connection Error'); ErrorCode := 0; ServerSocket1.Close; btSend.Enabled := False; btDisconnect.Enabled := False; btListen.Enabled := True; Statusbar1.SimpleText := 'No Connection'; end; //send test string on button click procedure TTCPServer.btSendClick(Sender: TObject); begin ServerSocket1.Socket.Connections[0].SendText(edSendData.Text); edSendData.Text := ''; end; //receive data handling procedure TTCPServer.OnClientRead(Sender: TObject; Socket: TCustomWinSocket); begin mbReceiveData.Text := mbReceiveData.Text + Socket.ReceiveText; end; //end connection from server side by button click procedure TTCPServer.btDisconnectClick(Sender: TObject); begin ServerSocket1.Close; btListen.Enabled := True; btSend.Enabled := False; btDisconnect.Enabled := False; Statusbar1.SimpleText := 'No Connection'; end; |
There are many ways you can send an email directly from Delphi ; the most simple one is to use the ShellExecute API call to send an email using the default e-mail client software installed on a user's machine; this approach is ok, but you are unable to send attachments in this way.
Sending Email Messages with Attachments using Delphi and Indy : \\Delphi\Email_Client\SendMail\MainUnit.pas
Have a look at this : A client that provides command line access to Lotus Notes email..
MAPI.
You'll have to add this function to your unit to be able to send APR packages form your application.
An example function that uses SendARP to get remote MAC address form IP address.
Indy uses blocking socket calls. ... Threading is almost always used with blocking sockets. ... Indy servers allocate a thread for each client connection. ... Plain text protocols can be debugged easily because they can be tested using a telnet session.
Veure \\Borland\Delphi7\Source\Indy\idicmpclient.pas
Indy is a blocking library, and the calling thread's message queue is blocked while Indy is doing its work. You need to place a TIdAntiFreeze component onto your form or an additional worker thread with INDY Indy's synchronous operations internally call into TIdAntiFreeze periodicaly, which then calls Application.ProcessMessages().
Async programming. O mira't això també : Indy is Blocking. Blocking is not Evil.
The only parts that are Indy specific are the Client component and the Button1Click method.
Client is a TIdTCPClient and is a component on the form. The following properties were altered from the default:
Button1Click is a method that is hooked to the OnClick event of Button1. When the button is clicked it executes this method.
The Indy portion of this method can be reduced to the following:
The only parts that are Indy specific are the IdTCPServer1 component, IdTCPServer1Connect method, and the IdTCPServer1Execute method.
IdTCPServer1 is a TIdTCPServer and is a component on the form. The following properties were altered from the default: * Active = True - Set the server to listen when the application is run. * DefaultPort = 6000 - An arbitrary number for this demo. This is the port the listener will listen on for incoming client requests.
The IdTCPServer1Execute method is hooked to the OnExecute event of the server. The OnExecute event is fired by the server after a client connection has been accepted. The OnExecute event is uniquely different from other events you may be familiar with. OnExecute is executed in the context of a thread. The thread the event is called from is passed in the AThread argument of the method. This is important as many OnExecute events may be executing at the same time. This was done with an event so that a server could be built without the requirement of building a new component.
The OnConnect is called after a connection has been accepted, and a thread created for it. In this server it is used to send the welcome message to the client. This could also be done in the OnExecute event if desired. The OnExecute event will be called repeatedly until the connection is disconnected or broken. This eliminates the need to check the connection and loop inside the event. IdTCPServer1Execute uses two basic Indy functions, ReadLn and WriteLn. ReadLn reads a line from the connection and WriteLn writes a line to the connection.
|
uses Ping;
...
const ADP_IP = '208.185.127.40'; (* http://delphi.about.com *)
begin
If Ping.Ping(ADP_IP) then
ShowMessage ( 'About Delphi Programming reachable !' ) ;
end;
|
I aquí és el codi : (requereix ICMP.DLL - mind access rights)
|
unit Ping;
interface
uses
Windows, SysUtils, Classes;
type
TSunB = packed record
s_b1, s_b2, s_b3, s_b4: byte;
end;
TSunW = packed record
s_w1, s_w2: word;
end;
PIPAddr = ^TIPAddr;
TIPAddr = record
case integer of
0: (S_un_b: TSunB);
1: (S_un_w: TSunW);
2: (S_addr: longword);
end;
IPAddr = TIPAddr;
function IcmpCreateFile : THandle; stdcall; external 'icmp.dll';
function IcmpCloseHandle (icmpHandle : THandle) : boolean; stdcall; external 'icmp.dll';
function IcmpSendEcho
( IcmpHandle : THandle ;
DestinationAddress : IPAddr ;
RequestData : pointer ;
RequestSize : Smallint ;
RequestOptions : pointer ;
ReplyBuffer : pointer ;
ReplySize : DWORD ;
Timeout : DWORD ) : DWORD; stdcall; external 'icmp.dll';
function Ping( InetAddress : string ) : boolean;
implementation
uses
WinSock;
function Fetch ( var AInput : string ;
const ADelim : string = ' ' ;
const ADelete : Boolean = true ) : string;
var
iPos: Integer;
begin
if ADelim = #0 then begin
// AnsiPos does not work with #0
iPos := Pos(ADelim, AInput);
end else begin
iPos := Pos(ADelim, AInput);
end;
if iPos = 0 then begin
Result := AInput;
if ADelete then begin
AInput := '';
end;
end else begin
result := Copy(AInput, 1, iPos - 1);
if ADelete then begin
Delete(AInput, 1, iPos + Length(ADelim) - 1);
end;
end;
end;
procedure TranslateStringToTInAddr ( AIP: string; var AInAddr ) ;
var
phe: PHostEnt;
pac: PChar;
GInitData: TWSAData;
begin
WSAStartup($101, GInitData);
try
phe := GetHostByName(PChar(AIP));
if Assigned(phe) then
begin
pac := phe^.h_addr_list^;
if Assigned(pac) then
begin
with TIPAddr(AInAddr).S_un_b do begin
s_b1 := Byte(pac[0]);
s_b2 := Byte(pac[1]);
s_b3 := Byte(pac[2]);
s_b4 := Byte(pac[3]);
end;
end
else
begin
raise Exception.Create('Error getting IP from HostName');
end;
end
else
begin
raise Exception.Create('Error getting HostName');
end;
except
FillChar(AInAddr, SizeOf(AInAddr), #0);
end;
WSACleanup;
end;
function Ping ( InetAddress : string ) : boolean;
var
Handle : THandle;
InAddr : IPAddr;
DW : DWORD;
rep : array[1..128] of byte;
begin
result := false;
Handle := IcmpCreateFile ;
if Handle = INVALID_HANDLE_VALUE then
Exit;
TranslateStringToTInAddr ( InetAddress, InAddr ) ;
DW := IcmpSendEcho ( Handle, InAddr, nil, 0, nil, @rep, 128, 0 ) ;
Result := (DW <> 0);
IcmpCloseHandle ( Handle ) ;
end;
end.
|
From
here
Error code list
Indi Project, conceptes.
If you already installed Indy components, you may do it the short way - put a IdICMPClient component in your form, fill in the property "Host" with the IP you want to ping, and write approximatively this :
Our initial code :
When Ping() exits, the ReplyStatus property contains the same information that is passed to the AReplyStatus parameter of the OnReply event. Ping() simply calls the OnReply handler right before exiting, passing it the ReplyStatus property, so you don't actually need to use the OnReply event in your example.
That being said, you are not processing the ReplyStatus data correctly. The BytesReceived field can be greater than 0 even if the ping fails. As its name implies, it simply reports how many bytes were actually received for the ICMP response. ICMP defines many different kinds of responses. The ReplyStatusType field will be set to the type of response actually received. There are 20 values defined:
If the ping is successful, the ReplyStatusType will be rsEcho,
and the ReplyData field will contain the (optional) data that was passed to the ABuffer parameter of Ping().
You might also want to pay attention to the FromIpAddress and ToIpAddress fields as well,
to make sure the response is actually coming from the expected target machine.
If a timeout occurs, the ReplyStatusType will be rsTimeOut instead.
url [****]
Atenció - si no hi ha conexió TCP/IP amb la xarxa, el codi anterior dona el següent error :
Per agafar el control d'aquest incident, s'ha de codificar d'aquesta manera :
Petit problema : si fem correr el programa dins el IDE de Delphi, el Debugger captura l'excepció. Si no volem que sigui així, podem mirar Ignoring Exceptions with Delphi's Integrated Debugger o mirar "Tools | Debugger Options | Language Exceptions | Stop on Delphi Exceptions" .
Have a close look at this {$APPTYPE CONSOLE} multi-thread code - \\Delphi\mqTT\Client_Library\synapse40\source\demo\scan\ :
En Pere fa servir aquest codi :
url ;
From Delphi Help :
Unit: IdSNMP.pas
IdSNMP.pas contains types and classes needed to implement a Simple Network Management Protocol (SNMP) client,
as described in the Internet Standards document
RFC 1157 - A Simple Network Management Protocol [SNMP]
(http://www.rfc-editor.org/rfc/rfc1157.txt)
Ports :
Simple SNMP client code sample :
Volem que s'obri una finestra "fill" (pero independent ?) en polsar un boto.
La ventana principal del programa (Main) se distingue de cualquier otra por el valor de la propiedad FormStyle, que debe ser fsMDIForm, no pudiendo existir en el mismo proyecto más de una ventana con éste atributo.
Las fichas hijas se caracterizan por tener el valor fsMDIChild en la propiedad FormStyle, lo que asegura su correcta asociación con la ventana principal.
C:\Program Files\Borland\Delphi7\Demos\ActiveX\OleCtnrs\MDImain.pas
From here
Get images
En Pere indica que sempre es pot fer així ...
Això és amb lo mínim que funciona :
How to change the default directory Delphi uses to save projects : select the Shortcut icon that you use to start up Delphi. Right click on the icon and select Properties. Where it says "Start in:" replace the string in that field with the directory you would like Delphi to default to when you save projects.
How to show a second form with an active title bar (url).
How to show/hide the Menu (url).
Used to save/restore values between executions. Save data in a file "project.ini" like this:
The OnCreate event of the main form is the perfect place to store the code needed to access the values in the application's initialization file. Get it into your program like this:
Main form's OnClose event is ideal for the "Save INI" part of the project.
url.
If you change the values during the program execution, they can be saved into the INI file using:
Save and restore main window position :
"ask" the Task Manager How Much Memory Is Your Delphi Program using (url).
URLs : Delphi Tips.
En efecte les DLL es poden carregar estàticament per linker o no,
llavors s'en pot fer una càrrega dinàmica per codi, amb LoadLibrary.
Un bon article que ho explica bé
url.
En resum, es complica el codi però et dóna flexibilitat. El que no pots és en un programa que tingui la DLL linkada estàticament, fer la comprovació amb càrrega dinàmica, perque abans de començar a executar-se el teu codi, i per tant fer la comprovació, el sistema operatiu donarà error de càrrega ja que no trobarà la DLL. Si la funcionalitat de MQ és crítica, que ho és, i la utilitzes arreu del teu programa, que ho fas, ho deixaria en estàtic. Si vols fer una comprovació prèvia, pots posar el teu programa en un BAT que abans d'arrancar el teu programa arranqui un petit EXE que faci la comprovació de prerrequisits.
Building a modern database application requires us to think of data in a relational way. The basic idea behind the relational model is that a database consists of a series of tables (or relations) that can be manipulated using operations that return tables or so-called views. Simply put, a database is best described as a collection of related data. A database may include many different tables. Tables are like grids where columns are called fields and rows are called ... rows.
A database is a collection of one or more tables that store data in a structured format. These tables, contain data that is represented by rows and fields. When a database consists of two or more tables, these tables generally contain separate yet related data.
Working with database data in Delphi can be really simple. Drop a TQuery on a form, set the SQL property, set Active and, voila, here's your database data in a DBGrid. Ok, you do need a TDataSource and a connection to a database, but that's just a few clicks away. Now you want to insert, update and delete data. That's also easy but can get messy. You fight with the corect SQL syntax, but finally have it laid out correctly. You introduce new tables, tables change in design ... and your simple task becomes slightly cumbersome :( Can all this be done easily? The answer is yes: use an ORM
Developers will learn how to design, develop and test a database application using ADO with Delphi. This course focuses on the most common uses of ADO in a Delphi application: Connecting to a database using TADOConnection, work with Tables and Queries, handle database exception, create reports, etc.
BDE is a common data access layer for all of Borland's products, including Delphi and C++Builder. The BDE consists of a collection of DLLs and utilities. The beauty of the BDE is the fact that all of the data manipulation is considered "transparent" to the developer. BDE comes with a set of drivers that enables your application to talk to several different types of databases. These drivers translate high-level database commands (such as open or post) and tasks (record locking or SQL construction) into commands specific to a particular database type.
ADO is a set of COM components (DLLs) that allow you to access databases as well as e-mail and file systems. Applications built with ADO components don't require the BDE. To access any kind of database with ADO, you'll of course need to have ADO/OLE DB libraries.
MS ADO programming model :
ADO provides a hierarchical object model, with, simplistically, a Connection object at the top,
Command and Recordset objects in the middle, and Field objects at the base.
The Connection object represents a connection to the data source with the connection strings. In BDE/Delphi a Connection object is a combination of the Database and Session components.
The Command object enables us to operate on a data source. Ir represents a command (also known as a query or statement) that can be processed to add, delete, query or update the data in a database.
The Recordset object is a result of a Query command. You can think of a Recordset as a Delphi Table or Query component. Each row that the Recordset returns consists of multiple Field objects.
Several other objects like: the Field object, the Parameter object and the Error object also exist in ADO model
One of the strengths of Delphi is the support for many databases using several data access technologies: the BDE, dbExpress, InterBase Express, ADO, Borland Data Providers for .NET, to name a few.
dbExpress is a light-weight, extensible, cross-platform, high-performance mechanism for accessing data from SQL servers.
dbExpress guide : collection of tutorials {*****}
Create 64-bit windows applications using Delphi XE7. XE7 Architect new user : 4.159 €, 4.949 amb IVA. XE7 starter edition new user : 248 € amb IVA.
Docu, delphi xe7 online, sockets demos, Internet demos, Indy cleint/server.
guided tour, whats new, 1000's of code examples {745 Delphi, 570 c++}, Berlin 738 Delphi examples, delphi VCL (Visual Component Library)
Instalacio "Embarcadero RAD Studio XE7 Architect" :
Atencio : Desactivar Internet abans d'instalar el Studio. En engegar l'instalacio, acceptar la pregunta d'engegar com Administrador.
Recomanacio : despres de l'instalacio, prohibiu el seu acces a internet amb regles del tallafocs.
By default, RAD Studio creates applications that target 32-bit versions of the Windows operating system.
To add x64 versions of Windows as a target platform, do
Now your project can be built for both Win32 and Win64 platforms. Also, you can just press F9 to execute your Win64 application.
Inclou CodeSite, dr BOB review
Esborra tots els .dcu
En executar el programa, dona "Socket error 10013 access denied" - s'ha d efer correr amb drets d'admnistrador.
Com se li diu al RAD que ho faci ?
Solution : run RAD as Admnistrator - change icon shortcut properties !
Lets call it "Chat", so here we have it ! [\\Delphi\UDP_chat]
A UDP server just provides a port where any device on the net can send UDP data blocks to.
i aquest
Si canvia la definició, (b) segueix sent valid, pero (a) pot ser no : "1".
Resposta : "compile" builds only changed files, whereas "build" rebuilds all files.
Solució:
NO funciona posar dins de Unit2 :
si Unit1 té una referencia (similar) a Unit2.
Però sí puc posar dins de Unit2 :
Try this: start Delphi and compile that default project with one blank form, this will produce an executable file of about 385 KB (Delphi 2006).
Now go to Project - Options - Packages and check the 'Build with runtime packages' check box.
Compile and run. Voila, the exe size is now around 18 KB.
By default the 'Build with runtime packages' is unchecked and every time we make a Delphi application,
the compiler links all the code your application requires to run directly into your application's executable file.
Your application is a standalone program and doesn't require any supporting files (like DLLs) - that's why Delphi exe's are so big.
url ;
|
Best place :
Delphi.About.com [Zarko Gajic],
Forum
A beginner's guide to Delphi programming Now (20170720) it is ThoughtCo |
| Delphi Basics [****], as First Program. |
| Swiss Delphi Center {****} |
| History of Delphi Strings |
| Arqueologia |
|
Retrieving volume's (disk / drive) serial number : URL A guide to developing Delphi programs in Windows API (without the use of the VCL) : URL Windows User Interface (MSDN). Delphi tips - Windows OS and API : URL, Scalabium. An introduction to hook procedures : URL |
| Codificació d' Excepcions |
| Colin Wilson's site (D3 & 4, D5, D6, D7, 2005 & 2006) |
| Custom Event log from here [\\Delphi\Magazines\TheDelphiMagazine\*.zip - 50 MB] |
| Service Application in Delphi |
|
Learn to program Delphi
part one,
part two.
Curs bàsic. |
| See Delphi section |
|
Delphi 4.0
shareware Programming Tools - see SVCOM.
DSP = Delphi Super Page ! And search engine ... Delphi Super Page mirror Nice links |
| A Service in C ! |
| Dr Bob's Delphi index |
| Source codes |
| Win32 at Borland |
| Tutorial [*****] |
| Tutorial (private) |
| Delphi tutorial |
| Tips and FAQs , as IP @, MAC @, etc. |
| Lots of questions |
| Delphi Graphics Info and Links. Algorithms. Tons of Links ! |
|
Delphi GDI
drawing (intro), from
Homepage.
They say :
Borland Delphi is a probably the best if not one of the most impressive and the richest programming environment known to mankind and Delphi 2005 absolutely has no comparison. |
Cursos :
|
| Delphi and Kylix programming zone. |
| Delphi and Kylix Help, Tutorials, etc. New ? |
| Kylix tips Torry's Delphi |
|
The Unofficial Newsletter of
Delphi Users ...
goes back as far as
1997 !
Read how to record and playback sound in a Delphi application |
| See Task Desk - Task Manager on desktop (Delphi + WinAPI). |
|
TP links page : url |
|
Linux ? El compilador es diu Free Pascal : http://en.wikipedia.org/wiki/Free_Pascal i té un IDE que es diu Lazarus : http://en.wikipedia.org/wiki/Lazarus_(software) |
| Delphi wiki |
|
Central Iowa Delphi Users Group (nice looking !) |
|
Using The Windows API In Delphi |
| LaunchPad : windir(), currdir(), ShellExecute(), Displaying Icons, Launching Files, Creating Controls At Runtime |
| Samples from Delphi.About.Com : {Zarko Gajic} |
| Sokoban (with source) |
| Boletin (num 50) interesante |
| Moving from VB to Delphi 2.0 |
| How to use Chilkat ActiveX components in Delphi. |
| Lots of tips (256) |
| Resources |
| Few Prog Samples |
| Chapter 4 for Delphi Unleashed 1.0: 16 Bit |
| Prevent memory leaks : here |
|
"The Big Brother" Delphi code toolkit : url, url, part 2 (wXP + dGina.dll)
|
| WikiDelphi 2010 & Anders Hejlsberg |
|
Few links :
|
|
|
|
Updated 20170724 (a)
|
|
Home
|
Top
|